package sdk.webview.fmc.com.fmcsdk.check.adapter;

import android.annotation.SuppressLint;
import android.graphics.Color;
import android.support.annotation.Nullable;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.List;

import sdk.webview.fmc.com.fmcsdk.R;
import sdk.webview.fmc.com.fmcsdk.check.bean.PopupBean;
import sdk.webview.fmc.com.fmcsdk.check.bean.StaffteamBean;
import sdk.webview.fmc.com.fmcsdk.util.KLog;

public class WorkGroupAdapter extends BaseQuickAdapter<PopupBean, BaseViewHolder> {
    public WorkGroupAdapter(int layoutResId,  List<PopupBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, PopupBean item) {
        TextView tvName = helper.getView(R.id.tv_name);
        tvName.setText(item.getName());
        helper.setBackgroundRes(R.id.tv_name,item.isSelect()?R.color.color_ff4f5:R.color.white);
        if (item.isSelect()){
            tvName.setBackgroundResource(R.drawable.shape_radius_8_solid_b2b2b2);
            tvName.setTextColor(Color.parseColor("#DC3C26"));
        }else {
            tvName.setBackgroundColor(Color.WHITE);
            tvName.setTextColor(Color.parseColor("#393A42"));
        }
    }
    @SuppressLint("NotifyDataSetChanged")
    public void setSelect(int position){
        for (int i=0;i<getData().size();i++){
            getData().get(i).setSelect(false);
        }
        getData().get(position).setSelect(true);
        KLog.e(position);
        notifyDataSetChanged();
    }
}
